<?php
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests;
use App\Model\AppUpgrade;
use JWTAuth;
use DB;

class AppApiController extends Controller
{

    public function __construct()
    {
        parent::__construct();
        view()->share([
            '_xApi' => 'am-in',
        ]);
    }
    
    function getAppList()
    {
        $data = array();
        $app = AppUpgrade::first();
        if (empty($app)) {
            $data['info'] = '获取数据失败';
            $data['status'] = false;
            return $data;
        }
        $data['status'] = true;
        $data['info'] = '成功获取信息';
        $app_data=array();

        $app_data['app1']['name']=$app['name_aone'];
        $app_data['app1']['url']=$app['url_aone'];
        $app_data['app1']['number']=$app['number_aone'];
        $app_data['app1']['is_update_one']=$app['is_update_one'];

        $app_data['app2']['name']=$app['name_atwo'];
        $app_data['app2']['url']=$app['url_atwo'];
        $app_data['app2']['number']=$app['number_atwo'];
        $app_data['app2']['is_update_two']=$app['is_update_two'];

        $app_data['app3']['name']=$app['name_athree'];
        $app_data['app3']['url']=$app['url_athree'];
        $app_data['app3']['number']=$app['number_athree'];
        $app_data['app3']['is_update_three']=$app['is_update_three'];

        $data['data'] = array_values($app_data);

        return response()->json($data);

    }
}
